package com.kmsoft.consumer.facade.controller;

import com.kmsoft.provider.facade.api.ProviderApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
public class ConsumerFacade {
    @Value("${spring.application.name:}")
    private String applicationName;
    @Resource
    private ProviderApi providerApi;

    @GetMapping("/test")
    public String test() {
        log.info("================local service:{}", applicationName);
        return applicationName;
    }

    @GetMapping("/call")
    public String test2() {
        String result = providerApi.call(applicationName);
        log.info("================local service:{} call service:{} success", applicationName,result);
        return result;
    }
}
